<template>
  <el-form-item label="API Path">
    <el-row>
      <el-col :span="2">
        <div class="littleSelectBorder">
          <el-select v-model="dataArr.protocol" placeholder="请选择" size="small" @change="protocolSelect">
            <el-option :label="item.value" :value="item.key" v-for="item of httpSelectData" :key="item.value"></el-option>
          </el-select>
        </div>
      </el-col>
      <el-col :span="2">
        <div class="littleSelectBorder">
          <el-select v-model="dataArr.method" placeholder="请选择" size="small" @change="methodSelect">
            <el-option :label="item.value" :value="item.key" v-for="item of requestSelectData" :key="item.value"></el-option>
          </el-select>
        </div>
      </el-col>
      <el-col :span="20">
        <el-input placeholder="请输入内容" size="small" v-model="dataArr.uri" class="input-with-select" @blur="burlChangeVal"></el-input>
      </el-col>
    </el-row>
  </el-form-item>
</template>

<script>
  export default {
    name: 'apiPath',
    props: ['form'],
    data() {
      return {
        dataArr: this.form,
        httpSelectData: [
          {
            key: 'http',
            value: 'http'
          },
          {
            key: 'https',
            value: 'https'
          }
        ],
        requestSelectData: [
          {
            key: 'POST',
            value: 'POST'
          },
          {
            key: 'GET',
            value: 'GET'
          },
          {
            key: 'PUT',
            value: 'PUT'
          },
          {
            key: 'DELETE',
            value: 'DELETE'
          },
          {
            key: 'HEAD',
            value: 'HEAD'
          },
          {
            key: 'OPTIONS',
            value: 'OPTIONS'
          },
          {
            key: 'PATCH',
            value: 'PATCH'
          }
        ]
      }
    },
    methods: {
      protocolSelect() {
        this.$emit('changeFormFun', this.dataArr)
      },
      methodSelect() {
        this.$emit('changeFormFun', this.dataArr)
      },
      burlChangeVal() {
        this.$emit('changeFormFun', this.dataArr)
      }
    }
  }
</script>

<style scoped>

</style>
